<html>

<head>
    <title>誉优品学</title>
    <!--<link rel="stylesheet" href="css/common.css">-->
  <!--<script language="javascript" src="./js/CLodopFuncs.js"></script>-->
  <script language="javascript" src="./js/LodopFuncs.js"></script>
    <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
      <embed id="LODOP_EM" type="application/x-print-lodop"  width=0 height=0 />
    </object>
  <style>

    @media print {
      body {
        width: 100%;
        margin: 0;
        padding: 0;
      }

      @page {
        margin: 0cm;
      }
    }

  </style>
</head>

<body>
    <div>
      备注：打印控件需要时间加载，可以点击多次，不行，请刷新页面。
    </div>
    <!-- <script src="http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script> -->
    <script src="./js/jquery-3.0.0.min.js"></script>
    <script src="//cdn.bootcss.com/moment.js/2.18.0/moment.min.js"></script>
    <script src="//cdn.bootcss.com/moment.js/2.18.0/locale/zh-cn.js"></script>
    <script>
      var LODOP
      $(function () {
        CheckIsInstall()
      })
      function getQueryString (name){
        var r = window.location.search.substr(1).match(new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"));
        if(r) {
          return r[2];
        }
        return null;
      }

      function formatDate (time , format ) {
        if (!time) return "";
        if (typeof time == "string") {
          time = parseInt(time, 10);
        }
        return moment(time).format(format || 'YYYY-MM-DD')
      }
      function CheckIsInstall() {
        try{
          var LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
          if (LODOP.VERSION) {
            if (LODOP.CVERSION)
              console.log("当前有C-Lodop云打印可用!\n C-Lodop版本:"+LODOP.CVERSION+"(内含Lodop"+LODOP.VERSION+")");
            else
              console.log("本机已成功安装了Lodop控件！\n 版本号:"+LODOP.VERSION);

          };
        }catch(err){
        }
      };

      function print(data, img) {
        CreatePrintPage(data, img)
        LODOP.PRINT();
      }

      function CreatePrintPage(data,img) {
        var totalAmount= data.courseOrder.totalAmount,
          discountAmount= data.courseOrder.totalAmount - data.courseOrder.payableAmount,
          payableAmount= data.courseOrder.payableAmount,
          paidAmount= data.courseOrder.paidAmount,
          owingAmount= data.courseOrder.payableAmount - data.courseOrder.paidAmount,
          courseOrderUpdate= formatDate ( data.courseOrder.updateTime),
          operateDate= moment().format('YYYY-MM-DD H:mm:ss'),
          regFrom= data.courseOrder.regFrom == 0 ? '线下' :'线上',
          studentNo= data.student.studentNo,
          studentName= data.student.name,
          address= data.campus.address,
          operator= data.principal,
          phoneNo = data.campus.phoneNo;
          campusPhoneNo= data.campus.phoneNo;
        LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
        LODOP.SET_PRINT_PAGESIZE (2, 0, 0,"A5");
        LODOP.ADD_PRINT_TEXT(35,280,130,25,"报名方式：" + regFrom);//报名方式
        LODOP.ADD_PRINT_TEXT(35,470,130,25,"绑定学员：");
        LODOP.ADD_PRINT_IMAGE(10,535,"100%","100%",img);//二维码

        LODOP.ADD_PRINT_TEXT(108,39,130,25,"待续费：" + owingAmount.toFixed(2));//欠费金额
        //学生编号
        LODOP.ADD_PRINT_TEXT(110,239,90,25,studentNo);//Top、Left、Width、Height
        //学生姓名
        LODOP.ADD_PRINT_TEXT(108,440,100,25,studentName);
        LODOP.ADD_PRINT_TEXT(75,700,70,25,studentNo);//学生编号
        LODOP.ADD_PRINT_TEXT(115,700,70,25,studentName);//学生姓名
        LODOP.ADD_PRINT_TEXT(145,700,70,25,totalAmount);//总金额
        LODOP.ADD_PRINT_TEXT(190,700,70,25,discountAmount);//优惠金额
        LODOP.ADD_PRINT_TEXT(270,700,70,25,payableAmount);//实收金额
//        LODOP.ADD_PRINT_TEXT(235,700,70,25,0.00);//使用账户金额
//        LODOP.ADD_PRINT_TEXT(325,700,70,25,0.00);//现金金额
//        LODOP.ADD_PRINT_TEXT(365,700,70,25,0.00);//pos
//        LODOP.ADD_PRINT_TEXT(405,700,70,25,0.00);//代金券
        //LODOP.ADD_PRINT_TEXT(465,700,70,25,operateDate); // 操作时间
        LODOP.ADD_PRINT_TEXT(452,700,70,25,operator); // 操作人员
        //LODOP.ADD_PRINT_TEXT(502,700,70,25,"报名方式：前台报名");//报名方式
        //20161104 新增收费金额
        LODOP.ADD_PRINT_TEXT(85,39,130,25,"收费金额：" + paidAmount);//收费金额
        LODOP.ADD_PRINT_TEXT(85,149,130,25,"已退金额：" + 0.00);//已退金额

        for(var i = 0 ;i < data.regDetailVos.length ;i++ ){
          var c  = data.regDetailVos[i]
          LODOP.ADD_PRINT_TEXT(165+30*i,17,72,80,c.courseClass.campusName);
          LODOP.SET_PRINT_STYLEA(0, "fontsize", 8);
          LODOP.ADD_PRINT_TEXT(165+30*i,84,50,80,c.courseClass.gradeName);
          LODOP.SET_PRINT_STYLEA(0, "fontsize", 8);
          LODOP.ADD_PRINT_TEXT(165+30*i,115,150,80, c.courseClass.className);
          LODOP.SET_PRINT_STYLEA(0, "fontsize", 8);
          LODOP.ADD_PRINT_TEXT(165+30*i,270,50,80,c.courseClass.roomName);
          LODOP.SET_PRINT_STYLEA(0, "fontsize", 8);
          LODOP.ADD_PRINT_TEXT(165+30*i,345,80,80, '缴'+c.studentReg.payLectureAmount+'讲  ');
          LODOP.SET_PRINT_STYLEA(0, "fontsize", 8);
          LODOP.ADD_PRINT_TEXT(165+30*i,380,80,80,c.courseClass.studyingTime);
          LODOP.SET_PRINT_STYLEA(0, "fontsize", 8);
          LODOP.ADD_PRINT_TEXT(165+30*i,530,200,80,formatDate( c.courseClass.startCourseTime , 'dddd YYYY-MM-DD' ) );//报名日期(星期)
          LODOP.SET_PRINT_STYLEA(0, "fontsize", 8);
        }

        LODOP.ADD_PRINT_TEXT(385,115,310,30,address);
        LODOP.ADD_PRINT_TEXT(420,115,310,30,phoneNo);
        LODOP.ADD_PRINT_TEXT(445,100,310,30,operator);//todo 操作员
        //LODOP.ADD_PRINT_TEXT(465,100,240,30,operateDate);//todo 打印日期
        LODOP.PREVIEW();
      };
    </script>


</body>

</html>
